﻿@using Toolkit.Web
@using Toolkit.Web.ViewComponents
@using Toolkit.Web.ViewComponents.DataGrid
@using Toolkit.Web.Mvc
@using Toolkit.Web.Mvc.ViewComponents

@model DataGridModel<Toolkit.Web.Mvc3.Examples.Controllers.DataGridController.GridEntry>

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section Title
{
    DataGrid
}

@section JavaScriptIncludes
{
    <script src="/Scripts/jqkit.min.js"></script>
    <script src="/Scripts/jqkit.plugins.min.js"></script>
    <script src="/Scripts/jqkit.components.min.js"></script>

    <script>
        function test_OnAfterLoad() {
            try { console.log('onAfterLoad'); } catch(error) {};
        }
        function test_OnBeforeDataBind(keyValues) {
            keyValues.push({ key: 'Test2.Name2', value: 'hello world (from event handler)' });
            try { console.log('onBeforeDataBind'); } catch(error) {}
        }
        function test_OnAfterDataBind() {
            try { console.log('onAfterDataBind'); } catch(error) {}
        }
        function test_OnBeforeDisplayChange() {
            try { console.log('onBeforeDisplayChange'); } catch(error) {}
        }
        function test_OnAfterDisplayChange() {
            try { console.log('onAfterDisplayChange'); } catch(error) {}
        }
        function test_OnDataBindOverride(data) {
            try { console.log('onDataBindOverride'); } catch(error) {}
        }
        function test_OnAfterRowSelectionChange(key, selected) {
            try { console.log('onAfterRowSelectionChange'); } catch(error) {}
        }
    </script>
}

@section StyleSheetIncludes
{
    <link href="/Content/StyleSheets/DataGrid.css" rel="Stylesheet" />
}

<div class="section">
    <h2>Example</h2>
    @Html.Partial("Index_Ajax", Model, ViewData)
</div>

<div class="section">
    <h2>No Records</h2>
    @{
        IEnumerable<Toolkit.Web.Mvc3.Examples.Controllers.DataGridController.GridEntry> noRecords =
            new List<Toolkit.Web.Mvc3.Examples.Controllers.DataGridController.GridEntry>();

        Html.Toolkit().DataGrid<Toolkit.Web.Mvc3.Examples.Controllers.DataGridController.GridEntry>(noRecords)
            .Columns(columns =>
            {
                columns.AddColumn("c0").Header(h => "Column 0").Body(item => item.Column0).Footer(f => "Column 0");
                columns.AddColumn("c1").Header(h => "Column 1").Body(item => item.Column1).Footer(f => "Column 1");
                columns.AddColumn("c2").Header(h => "Column 2").Body(item => item.Column2).Footer(f => "Column 2");
                columns.AddColumn("c3").Header(h => "Column 3").Body(item => item.Column3).Footer(f => "Column 3");
            })
            .RowHeight(25, 25, 25, 25, 25)
            .Header(h => "Header of Grid")
            .Footer(f => "Footer of Grid")
            .DefaultColumnHeader(h => "Default Header")
            .DefaultColumnBody(h => "Default Body - this is long text that may get cut off depending on column width")
            .DefaultColumnFooter(h => "Default Footer")
            .AddAdditionalHiddenMarkup(h => "Hidden Tag 1")
            .AddAdditionalHiddenMarkup(h => "Hidden Tag 1")
            .NoResultsMarkup(t => "No records found.")
            .Render();
    }
</div>